﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace GW2_Marketeer__WPF_
{
    #region enumerations
    public enum Profession
    {
        Armorsmith, Artificer, Cook, Huntsman, Jeweler, Leatherworker, Tailor, Weaponsmith,cItem
    };
    #endregion



    #region classes
    class Recipe : INotifyPropertyChanged
    {
        #region private variables
        private string _name;
        private Profession _prof;
        private List<Tuple<Recipe, int>> _components;
        private int _skillReq;
        private int _levelReq;
        private GWItem _item;
        #endregion

        #region functions
        public Recipe()
        {
            _item = null;
            _components = new List<Tuple<Recipe, int>>();
        }

        public void AddComponent(Recipe r, int num)
        {
            _components.Add(new Tuple<Recipe, int>(r, num));
        }

        public int GetNumComponents()
        {
            return _components.Count;
        }

        public Recipe GetComponentRecipe(int index)
        {
            return _components[index].Item1;
        }

        public int GetComponentQuantity(int index)
        {
            return _components[index].Item2;
        }
        #endregion  





        #region properties
        public string Name
        {
            get { return _name; }
            set
            {
                _name = value;
                NotifyPropertyChanged("Name");
            }
        }
        public Profession Prof
        {
            get { return _prof; }
            set
            {
                _prof = value;
                NotifyPropertyChanged("Prof");
            }
        }
        public int SkillReq
        {
            get { return _skillReq; }
            set
            {
                _skillReq = value;
                NotifyPropertyChanged("SkillReq");
            }
        }
        public int LevelReq
        {
            get { return _levelReq; }
            set
            {
                _levelReq = value;
                NotifyPropertyChanged("LevelReq");
            }
        }

        public GWItem Item 
        {
            get { return _item ?? (_item = new GWItem(Name)); }
            set
            {
                _item = value;
                NotifyPropertyChanged("Item");
            }
        }
        #endregion

        #region INotifyPropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;
        public void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion
    }   
    #endregion
}